require('scss/base.scss');

//安装Vuex
import Vue from 'vue'
//js
import format from 'js/format'
import popup from 'js/popup'
require('js/util')
import config from 'js/config'
import server from 'js/server'

import ElementUI from 'element-ui';
Vue.use(ElementUI);

let vue = new Vue({
    el:'#app',
    data:{
        search:{
            pageNum:1, //	否	int	页码，默认1
            pageSize:10000, //	否	int	每页展示个数，默认10
            param:"", //	否	String	查询参数
        },
        list:[],
        dialog:{
            show:false,
            bookName:'', //	是	string	绘本名称
            isbn:'', //	是	string	书号
            lockUser:'', //	是	string	绑定人
        }
    },
    mounted() {
        this.$nextTick(()=>{
            this.getList();
        })
    },
    methods:{
        getList(){
            let param = JSON.parse(JSON.stringify(this.search));
            util.ajax({
                url: config.baseApi + 'm-server/api/bookSearch/getBookSearchList',
                data: param,
                success:(data=>{
                    this.list = data.data.list;
                })
            })
        },
        bindUserShow(item){
            this.dialog = {
                show: true,
                bookName: item.bookName, //	是	string	绘本名称
                isbn: item.isbn, //	是	string	书号
                lockUser: '', //	是	string	绑定人
            }
        },
        bindUser(){
            let param = JSON.parse(JSON.stringify(this.dialog));
            delete param.show;
            util.ajax({
                url: config.baseApi + 'm-server/api/bookSearch/lockUser',
                data:param,
                success:()=>{
                    popup.miss({content:'绑定成功！'});
                    this.dialog.show = false;
                    this.getList();
                }
            })
        }
    }
})
window['vue'] = vue;
